package com.zyj.websocket2;

import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.WebSocketSessionDecorator;

import java.io.IOException;

/**
 * 原来session对象的装饰器
 * 发送message变成了同步的
 */
public class MyConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorator {

    public MyConcurrentWebSocketSessionDecorator(WebSocketSession session) {
        super(session);
    }

    @Override
    public synchronized void sendMessage(WebSocketMessage<?> message) throws IOException {
        getDelegate().sendMessage(message);
    }

}
